package Interfazeak;
/**
 * 
 * @author Txantxangorriak
 *
 */
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.border.EmptyBorder;

import Futbol_Liga.Jardunaldia;
import Futbol_Liga.Liga;

public class EI_Kiniela extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					EI_Kiniela frame = new EI_Kiniela();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public EI_Kiniela() {
		setTitle("Kiniela");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 478, 371);
		contentPane = new JPanel();
		contentPane.setBackground(Color.BLUE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblJardunaldia = new JLabel("Jardunaldia");
		lblJardunaldia.setFont(new Font("Times New Roman", Font.BOLD, 15));
		lblJardunaldia.setForeground(Color.WHITE);
		lblJardunaldia.setBounds(27, 30, 136, 15);
		contentPane.add(lblJardunaldia);
		
		final JComboBox<String> comboBox = new JComboBox<String>();
		comboBox.setBounds(116, 26, 123, 24);
		final Liga liga=Liga.getLiga();
		java.util.Iterator<Jardunaldia> it = liga.getJardunaldiak().getIteratzailea();
		while(it.hasNext()){
		comboBox.addItem(it.next().getData());
		}
		contentPane.add(comboBox);
		
		final JButton btnOnartu = new JButton("ONARTU");
		btnOnartu.setBounds(335, 297, 117, 25);
		
		btnOnartu.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				
				String kiniela=liga.kiniela(comboBox.getSelectedItem().toString());
				JTextPane textPane = new JTextPane();
				textPane.setBounds(12, 79, 413, 200);
				textPane.setText(kiniela);
				contentPane.add(textPane);
		
				
				btnOnartu.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						
						 EI_MENUA fl= new EI_MENUA();
	          				fl.setVisible(true);
	          				EI_Kiniela.this.setVisible(false);
		
			}});
	  }});
		contentPane.add(btnOnartu);
		
		System.out.println("KINIELA");
		
		
	}
}
